<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <pre>
var arr = [
    {id: 1,created: '2016-05-04 15:12:40',content: '1'},
    {id: 2,created: '2016-04-06 15:12:40',content: '2'},
    {id: 3,created: '2016-04-02 15:12:40',content: '3'},
]
将上面数据转换成下面数据格式
方式:(1)使用原生的js
(2)使用lodash
提示
思路:(1)思考转换成下面这种数据结果需要做哪些内容
        分组
        排序
        数据结构
(2)先做最简单内容
需要用到操作:
(1)数组map,sort
(2)lodash的map,group,链式调用
var map = [
    {month: '4月', data: [//(1)按月份分组,并且月份由小到大
        {id: 3,created: '2016-04-02 15:12:40',content: '3'},//(2)按时间排序,由远到近
        {id: 2,created: '2016-04-06 15:12:40',content: '2'}
    ]},
    {month: '5月', data: [
    {id: 1,created: '2016-05-04 15:12:40',content: '1'}
    ]}
]
    </pre>
</body>
<script>
//原始数据
var arr =[
    {id: 1,created: '2016-05-04 15:12:40',content: '1'},
    {id: 2,created: '2016-04-06 15:12:40',content: '2'},
    {id: 3,created: '2016-04-02 15:12:40',content: '3'},
]
// 排序:按照日期升序排序
arr.sort((a,b)=>new Date(a.created)-new Date(b.created))
console.log(arr);
// 分组: 按月份放在一起
//数据结构: 对象数组,month,data
</script>

</html>
